<?php
require_once "config.php";
require_once 'class/class.phpmailer.php';
//error_reporting(false);
$err_msg=  isset($_POST['err_msg'])?$_POST['err_msg']:'';

//print_r($member_orders);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hotels With Offers</title>
<script language="Javascript" type="text/javascript" src="js/jquery-1.4.1.js"></script>
<script language="Javascript" type="text/javascript" src="js/jquery.lwtCountdown-1.0.js"></script>
<script language="Javascript" type="text/javascript" src="js/misc.js"></script>
<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.validate.js"></script>


</head>

<body>
<div id="wrapper">
    <?php require_once 'top_header.php'; ?>    
<div class="contentPane">
  <div id="sidebar">
    <span class="menu"><img src="images/call.png" alt="Advertise with Hotel with Offers" class="callus"  /></span>
    <div class="joinus">
      <h1>INVITE A FRIEND</h1>
      <h2>Tell a friend and win Rs100.00</h2>
      <div class="joinbtn"><a href="#">LEARN&nbsp;MORE</a></div>
     </div>
    <div class="reserve"><span class="reserveitem">Reserved for :</span> <span class="reserveitem">advertising</span> <span class="reserveitem">latest news</span> <span class="reserveitem">soon ending deals &amp; offers</span></div>
  </div>
  <div class="leftPane">
    <div class="mainMenu"><?php require_once 'main_menu.php'; ?></div>
    <?php require_once 'newsletter_plug.php'; ?>
    
    <div>
        <?php if (!empty($err_msg)) :?>            
            <?php if ($err_msg=='success') :?>            
                <div class="success_msg">Your message sent successfully!</div>
            <?php else:?>
                <div class="error">Your message sending failed!</div>
            <?php endif;?>
        <?php endif;?>
        <?php if(!isset($_SESSION['member_id'])):?>
        <div>
            <div class="header">Invite Your Friends & Family</div>
            <div class="sub_content">
                <div class="title">How do I invite a friend?</div>
                <div class="detail">
                    Once you become a member you will be able to send invitations. There are three ways to invite people.<br />
                    1) You can share the site using Facebook and Twitter. <br />
                    2) Sending out emails.<br />
                    3) Cutting and pasting your personal link.<br />
                </div>
            </div>
        </div>
        <?php else :
            $en_key='Oi56TCVH@#%^&*TFf78@hey@2';
            $enc = new Encryption();
            //echo "<br>member_id: ".$_SESSION['member_id'];
            $enc_member_id = $enc->encrypt($en_key, $_SESSION['member_id']);
            $share_url="http";
            if ($_SERVER["HTTPS"] == "on") {$share_url .= "s";}
            $share_url .= "://";
            $share_url .= $_SERVER["SERVER_NAME"]."?k=".$enc_member_id;
?>
        <div>
            <div id="info">
                <h3>Invite Your Friends & Family </h3>
                <div>
                    We are giving you Rs 100 credit when someone you invite buys their first voucher. 
                    We want to reward you for sharing our great deals and there is no limit on how much you can earn! Have some questions?
                    <a href="javascript();" id="faq">Click Here</a>
                    <div id="answers">
                        <div>
                            <h4>How do I invite a friend?</h4>
                            <span>There are three ways to invite people. 1) facebook or twitter, 2) cutting and pasting your own unique personal link, 3) by email.</span>
                        </div>
                        <div>
                            <h4>How do I earn credits?</h4>
                            <span>If someone you invited purchases a voucher, you will automatically earn 100 Rupees in credit.</span>
                        </div>
                        <div>
                            <h4>How do I view my credits?</h4>
                            <span>You can view your credits by clicking on My Account > My Credits.</span>
                        </div>
                    </div>
                </div>
            </div>
            <div id="one">
                <div class="title">1. Connect & Share with friends on Facebook, Twitter, or Google.</div>
                <div>
                    <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
                    <a href="https://twitter.com/home/?status=<?php echo urlencode($share_url);?>"><img src="images/twitter.jpg" border="0"  /></a> <a href="" onclick="window.open('https://www.facebook.com/sharer.php?u=<?php echo urlencode($share_url);?>','','width=800,height=450,left=200');return false;"><img src="images/fb.jpg" border="0" /></a> <g:plusone></g:plusone>
                </div>
            </div>
            <div id="two">
                <div class="title">2. Personal Link copy + paste your personal link into your blog, email or IM</div>
                <div>                    
                    <?php echo $share_url;?>
                </div>
            </div>
            <div id="three">
                <div class="content">
                <h4>3. Emails <span>send email invitations to your friends and family.</span></h4>
                    <form id="invitation" name="invitation" action="" method="post">
                        <div>
                            <div style="" id="grid_invite" class="grid">
                                <table cellspacing="0" cellpadding="0" class="border">
                                    <tbody>
                                        <tr id="headings_invite" class="headings">
                                            <th style="width:120px"> First Name </th>										<th style="width:160px"> Last Name </th>
                                            <th style="width:205px"> Email </th>
                                            <th class="last"></th>
                                        </tr>
                                        <tr id="_1334262818280_280">
                                            <td><input type="text" style="width:128px" class="field" value="" name="firstname" id="firstname"></td>
                                            <td><input type="text" style="width:168px" class="field" value="" name="lastname" id="lastname"></td>
                                            <td><input type="text" style="width:218px" class="field" value="" name="email" id="email"></td>
                                        </tr>

                                    </tbody>
                                </table>
                            </div>                                                           
                        </div>

                        <br>
                        <div class="left_note">
                            <textarea style="width:550px" cols="20" rows="5" name="description"></textarea>
                            <div style="font-weight:bold; color:#333;"><div class="right_send">
                            <input class="signUpButton" type="button" value="Invite" name="invite_friend" id="invite_friend" onclick="validate_form(this.form);">
                        </div> Personal note: (optional) </div>
                        </div>

                        <div class="clear_both"><span> </span></div>
                </form>
                <script type="text/javascript">
                function validate_form(frm){
                    var fname=document.getElementById('firstname').value;
                    //var lname=document.getElementById('lastname');
                    var email=document.getElementById('email').value;
                    //var dsc=document.getElementById('description');
                    var err='';
                    if (trim(fname)==''){
                        err='-First Name cannot be blank';
                    }
                    if (trim(email)=='' || !validate(frm.id, 'email')){
                        err+='\n-Invalid email';
                    }
                    if (err.length>0){
                        alert(err);
                        return false;
                    }
                    frm.action='invitation_email.php';
                    frm.submit();
                }  
                
                function validate(form_id,email) {
                    //alert(form_id);
                    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                    var address = document.forms[form_id].elements[email].value;                    
                    //alert(address);
                    if(reg.test(address) == false) {
                        //alert('Invalid Email Address');
                        return false;
                    }
                    return true;
                }
                
                function trim(stringToTrim) {
                    return stringToTrim.replace(/^\s+|\s+$/g,"");
                }
                </script>
            </div>
            </div>
        </div>
        <?php endif;?>
    </div>
    <div class="clear"></div>
</div>
</div>
<div class="clear"></div>
</div>
<div id="footerWrapper">
<?php require_once 'footer.php'; ?>
</div>
</body>

<script language="javascript" type="text/javascript">
    
function submit_now(){
    
}
</script>
</html>
